package com.ldy.transmit.io;

import java.io.IOException;

import org.springframework.core.io.ByteArrayResource;
import org.springframework.web.multipart.MultipartFile;

public class MultipartFileResource extends ByteArrayResource{

    private String fileName;

    public MultipartFileResource(MultipartFile multipartFile) throws IOException {
        super(multipartFile.getBytes());
        this.fileName = multipartFile.getOriginalFilename();
    }

    /**
     * 必须实现getFileName方法，不然Resource*Converter会当做普通的字符串来处理，而不是multipartFile
     */
    @Override
    public String getFilename() {
        return this.fileName;
    }
}
